<template>
  <div class="app-page-box">
    <div class="app-page">
      <a-form layout="inline" :model="queryForm" class="query-form">
        <a-form-item label="">
          <a-input v-model:value="queryForm.bussNo" placeholder="请输入业务编号" style="width: 200rem" />
        </a-form-item>

        <a-form-item label="">
          <a-input v-model:value="queryForm.customer" placeholder="请输入承租人姓名" style="width: 200rem" />
        </a-form-item>
        <a-form-item label="">
          <a-select placeholder="请选择任务状态" v-model:value="queryForm.taskStatus" style="width: 200rem">
            <a-select-option value="01"> 待签约</a-select-option>
            <a-select-option value="02"> 待提交</a-select-option>
            <a-select-option value="03"> 已提交</a-select-option>
          </a-select>
        </a-form-item>

        <a-form-item label="">
          <a-select placeholder="请选择主办经理" v-model:value="queryForm.sponsorId" style="width: 200rem">
            <a-select-opt-group v-for="item in sponsorList" :key="item.depart_code">
              <template #label>
                <span>
                  {{ item.depart_name }}
                </span>
              </template>
              <a-select-option v-for="sub in item.list" :key="sub.user_id" :value="item.user_id"> {{ sub.user_name }}</a-select-option>
            </a-select-opt-group>
          </a-select>
        </a-form-item>
        <a-form-item>
          <a-button type="primary" class="submit" @click="onSubmit" size="small"> 查询 </a-button>
          <a-button size="small"> 重置 </a-button>
        </a-form-item>
      </a-form>

      <a-table :pagination="false" :dataSource="dataSource" :columns="columns" :scroll="{ x: 2000, y: 300 }">
        <template #operate="{ record }">
          <a-link @click="onView">chakn</a-link>
        </template>
      </a-table>
      <a-pagination class="pager" :total="50" show-size-changer show-quick-jumper />
    </div>
  </div>
</template>

<script setup>
  import { ref, onMounted } from 'vue';
  import { useRoute, useRouter } from 'vue-router';
  import Back from '/@/components/go-back/index.vue';
  import { htSignApi } from '/@/api/system/htSign';
  import { Modal } from 'ant-design-vue';
  const router = useRouter();
  const queryForm = ref({
    leaseMode: '',
    customer: '',
    taskStatus: '01',
    sponsorId: '',
  });
  const leaseMode = ref([
    {
      optionCode: 'HZ01',
      display_default: '1',
      parent_code: '',
      optionName: '农机零售',
      status: '1',
    },
    {
      optionCode: 'HZ02',
      display_default: '1',
      parent_code: '',
      optionName: '售后回租',
      status: '1',
    },
    {
      optionCode: 'HZ03',
      display_default: '1',
      parent_code: '',
      optionName: '农机法人',
      status: '1',
    },
    {
      optionCode: 'HZ04',
      display_default: '1',
      parent_code: '',
      optionName: '农机库融',
      status: '1',
    },
    {
      optionCode: 'HZ05',
      display_default: '1',
      parent_code: '',
      optionName: '环卫法人',
      status: '1',
    },
    {
      optionCode: 'HZ06',
      display_default: '1',
      parent_code: '',
      optionName: '环卫零售',
      status: '1',
    },
  ]);
  const sponsorList = ref([
    {
      depart_code: '19001',
      list: [
        {
          user_id: '000197',
          user_name: '谢卓芯',
        },
        {
          user_id: '000146',
          user_name: '邵文博',
        },
        {
          user_id: '000111',
          user_name: '孙雨',
        },
        {
          user_id: '000125',
          user_name: '王卓雅',
        },
        {
          user_id: '000129',
          user_name: '王鼎',
        },
        {
          user_id: '000132',
          user_name: '韩双伦',
        },
        {
          user_id: '000168',
          user_name: '李兆民',
        },
        {
          user_id: '000162',
          user_name: '张语桐',
        },
        {
          user_id: '000092',
          user_name: '庄立强',
        },
        {
          user_id: '000181zb',
          user_name: '主办审批人员',
        },
        {
          user_id: '000160',
          user_name: '宋紫鑫',
        },
        {
          user_id: '000185',
          user_name: '时成志2',
        },
        {
          user_id: '000148',
          user_name: '李维安',
        },
        {
          user_id: '000149',
          user_name: '肖扬',
        },
        {
          user_id: '000152',
          user_name: '安蕾',
        },
      ],
      depart_name: '现代农业业务部二部',
    },
    {
      depart_code: '20001',
      list: [
        {
          user_id: 'A00143',
          user_name: 'A客户经理测试员',
        },
        {
          user_id: '000167',
          user_name: '高强',
        },
        {
          user_id: '000158',
          user_name: '李继韩',
        },
        {
          user_id: '000176',
          user_name: '胡阳',
        },
        {
          user_id: '000127',
          user_name: '冷云峰',
        },
        {
          user_id: '000123',
          user_name: '方禹博',
        },
        {
          user_id: '000147',
          user_name: '李诺',
        },
        {
          user_id: '000145',
          user_name: '赵思泽',
        },
        {
          user_id: '000163',
          user_name: '曲思铭',
        },
        {
          user_id: '000159',
          user_name: '韩婷婷',
        },
      ],
      depart_name: '现代农业业务部三部',
    },
    {
      depart_code: '12002',
      list: [
        {
          user_id: '000181xb',
          user_name: '协办审批人员',
        },
        {
          user_id: '000181fz',
          user_name: '负责人审批人员',
        },
      ],
      depart_name: '运营科技部',
    },
    {
      depart_code: '11001',
      list: [
        {
          user_id: '000131',
          user_name: '刘颖霖',
        },
        {
          user_id: '000166',
          user_name: '孙家音',
        },
        {
          user_id: '000157',
          user_name: '于洋',
        },
        {
          user_id: '000073',
          user_name: '胡远鹏',
        },
        {
          user_id: '000150',
          user_name: '官新鹏',
        },
        {
          user_id: '0001800',
          user_name: '孙志阳2',
        },
        {
          user_id: '000121',
          user_name: '刘剑',
        },
        {
          user_id: '000181',
          user_name: '时成志',
        },
        {
          user_id: '000161',
          user_name: '姜金亮',
        },
      ],
      depart_name: '现代农业业务部一部',
    },
    {
      depart_code: '12004',
      list: [
        {
          user_id: '000122',
          user_name: '于靖麒',
        },
        {
          user_id: '000109',
          user_name: '冯晶',
        },
      ],
      depart_name: '资产运营部',
    },
  ]);
  const dataSource = ref([
    {
      leaseTerm: 17,
      orderType: null,
      redoReason: '线下退汇:第三版线上放款测试',
      sponsorName: '刘剑',
      jointlyName: null,
      taskTypeName: '合同签约',
      ownerName: null,
      signing_count: 0,
      raiseFunds: 550000.0,
      custId: null,
      id: '89236206a2ec49e39ea07015cada2b51',
      leaseholder: '时成志',
      redoStatus: '04',
      hgName: 'esigntest哈银金融租赁有限责任公司PAAC',
      brandName: '艾禾',
      total_count: 4,
      unsign_count: 0,
      custName: '时成志',
      earningRate: '0.11959689',
      signed_count: 4,
      bussNo: 'NJZL-HZ-202410-0403',
      deductStatus: '01',
      taskName: '待处理',
      actions: {
        BTN_SIGN: '合同面签',
      },
      startDate: '2025-01-13',
      createName: null,
      leaseMode: 'HZ01',
    },
    {
      leaseTerm: 12,
      orderType: null,
      sponsorName: '赵思泽',
      jointlyName: null,
      taskTypeName: '合同签约',
      ownerName: null,
      signing_count: 0,
      raiseFunds: 100000.0,
      custId: null,
      id: '7106ff318fce4fbd8dfbc35bb76655cf',
      leaseholder: '公维鑫',
      hgName: 'esigntest哈银金融租凭有限责任公司PAAD',
      brandName: '艾禾',
      total_count: 6,
      unsign_count: 6,
      custName: '公维鑫',
      earningRate: '0.09344904',
      signed_count: 0,
      bussNo: 'NJZL-HZ-202502-0021',
      deductStatus: '01',
      taskName: '待处理',
      actions: {
        BTN_SIGN: '合同面签',
      },
      startDate: '2025-02-27',
      createName: null,
      leaseMode: 'HZ01',
    },
    {
      leaseTerm: 12,
      orderType: null,
      sponsorName: '赵思泽',
      jointlyName: null,
      taskTypeName: '合同签约',
      ownerName: null,
      signing_count: 0,
      raiseFunds: 100000.0,
      custId: null,
      id: '14cdd6fef5c542d29229ea79349c4f89',
      leaseholder: '公维鑫',
      hgName: 'esigntest哈银金融租凭有限责任公司PAAD',
      brandName: '中联重科',
      total_count: 6,
      unsign_count: 6,
      custName: '公维鑫',
      earningRate: '0.09077648',
      signed_count: 0,
      bussNo: 'NJZL-HZ-202502-0011',
      deductStatus: '01',
      taskName: '待处理',
      actions: {
        BTN_SIGN: '合同面签',
      },
      startDate: '2025-02-22',
      createName: null,
      leaseMode: 'HZ01',
    },
    {
      leaseTerm: 12,
      orderType: null,
      sponsorName: '赵思泽',
      jointlyName: null,
      taskTypeName: '合同签约',
      ownerName: null,
      signing_count: 0,
      raiseFunds: 90000.0,
      custId: null,
      id: 'ea415c1fa3fd4a668d4c7678255d5142',
      leaseholder: 'esigntest哈银金融租凭有限责任公司PAAD',
      hgName: 'esigntest哈银金融租凭有限责任公司PAAD',
      brandName: '中机美诺',
      total_count: 11,
      unsign_count: 11,
      custName: 'esigntest哈银金融租凭有限责任公司PAAD',
      earningRate: '0.0951806',
      signed_count: 0,
      bussNo: 'NJZL-HZ-202410-0074',
      deductStatus: null,
      taskName: '待处理',
      actions: {
        BTN_SIGN: '合同面签',
      },
      startDate: '2024-10-15',
      createName: null,
      leaseMode: 'HZ03',
    },
    {
      leaseTerm: 13,
      orderType: null,
      sponsorName: '时成志',
      jointlyName: null,
      taskTypeName: '合同签约',
      ownerName: null,
      signing_count: 0,
      raiseFunds: 70000.0,
      custId: null,
      id: '2b14f5d7d1b148f3af9a127cfc067b9f',
      leaseholder: '时成志',
      hgName: '',
      brandName: '福龙马',
      total_count: 3,
      unsign_count: 0,
      custName: '时成志',
      earningRate: '0.09785415',
      signed_count: 3,
      bussNo: 'HWZL-LS-202501-0004',
      deductStatus: '01',
      taskName: '待处理',
      actions: {
        BTN_SIGN: '合同面签',
      },
      startDate: '2025-01-08',
      createName: null,
      leaseMode: 'HZ06',
    },
    {
      leaseTerm: 24,
      orderType: null,
      sponsorName: '时成志',
      jointlyName: null,
      taskTypeName: '合同签约',
      ownerName: null,
      signing_count: 0,
      raiseFunds: 1000000.0,
      custId: null,
      id: '5bc211cd4b424ccf914f7512d25973c2',
      leaseholder: 'esigntest哈银金融租赁有限责任公司PAAC',
      hgName: '',
      brandName: '中联重科',
      total_count: 10,
      unsign_count: 0,
      custName: 'esigntest哈银金融租赁有限责任公司PAAC',
      earningRate: '0.07464201',
      signed_count: 10,
      bussNo: 'TYZL-HZ-202411-0012',
      deductStatus: null,
      taskName: '待处理',
      actions: {
        BTN_SIGN: '合同面签',
      },
      startDate: '2024-11-12',
      createName: null,
      leaseMode: 'HZ05',
    },
    {
      leaseTerm: 23,
      orderType: null,
      sponsorName: '时成志',
      jointlyName: null,
      taskTypeName: '合同签约',
      ownerName: null,
      signing_count: 0,
      raiseFunds: 100000.0,
      custId: null,
      id: '41b8fd05a84349dcb819b6d108f2e229',
      leaseholder: 'esigntest哈银金融租赁有限责任公司PAAC',
      hgName: '',
      brandName: '中联重科',
      total_count: 9,
      unsign_count: 0,
      custName: 'esigntest哈银金融租赁有限责任公司PAAC',
      earningRate: '0.06570257',
      signed_count: 9,
      bussNo: 'NJZL-KR-202411-0012',
      deductStatus: null,
      taskName: '待处理',
      actions: {
        BTN_SIGN: '合同面签',
      },
      startDate: '2025-01-09',
      createName: null,
      leaseMode: 'HZ04',
    },
    {
      leaseTerm: 24,
      orderType: null,
      sponsorName: '时成志2',
      jointlyName: null,
      taskTypeName: '合同签约',
      ownerName: null,
      signing_count: 0,
      raiseFunds: 1000000.0,
      custId: null,
      id: '8b6c20bac9d74f96b5558ba146136e26',
      leaseholder: 'esigntest哈银金融租赁有限责任公司PAAC',
      hgName: '',
      brandName: '福龙马',
      total_count: 15,
      unsign_count: 0,
      custName: 'esigntest哈银金融租赁有限责任公司PAAC',
      earningRate: '0.18283611',
      signed_count: 15,
      bussNo: 'HYZL-HZ-202411-0006',
      deductStatus: null,
      taskName: '待处理',
      actions: {
        BTN_SIGN: '合同面签',
      },
      startDate: '2024-11-19',
      createName: null,
      leaseMode: 'HZ05',
    },
    {
      leaseTerm: 12,
      orderType: null,
      sponsorName: '赵思泽',
      jointlyName: null,
      taskTypeName: '合同签约',
      ownerName: null,
      signing_count: 0,
      raiseFunds: 500000.0,
      custId: null,
      id: '9d27719a67dd4c1085afc906643a89dc',
      leaseholder: 'esigntest哈银金融租凭有限责任公司PAAD',
      hgName: '',
      brandName: '福龙马',
      total_count: 12,
      unsign_count: 0,
      custName: 'esigntest哈银金融租凭有限责任公司PAAD',
      earningRate: '0.0004099',
      signed_count: 12,
      bussNo: 'HWZL-FR-202411-0009',
      deductStatus: null,
      taskName: '待处理',
      actions: {
        BTN_SIGN: '合同面签',
      },
      startDate: '2024-11-29',
      createName: null,
      leaseMode: 'HZ05',
    },
    {
      leaseTerm: 24,
      orderType: null,
      sponsorName: '魏国鹏',
      jointlyName: null,
      taskTypeName: '合同签约',
      ownerName: null,
      signing_count: 0,
      raiseFunds: 1500000.0,
      custId: null,
      id: 'af3e7fa61f544d6e9ae0b4ff11b455aa',
      leaseholder: '魏国鹏',
      hgName: '',
      brandName: '中联重科',
      total_count: 3,
      unsign_count: 3,
      custName: '魏国鹏',
      earningRate: '0.08334996',
      signed_count: 0,
      bussNo: 'HWZL-LS-202411-0008',
      deductStatus: '01',
      taskName: '待处理',
      actions: {
        BTN_SIGN: '合同面签',
      },
      startDate: '2024-11-29',
      createName: null,
      leaseMode: 'HZ02',
    },
  ]);
  const columns = ref([
    {
      title: '序号',
      key: 'index',
      dataIndex: 'index',
      width: 70,
      customRender: ({ text, record, index }) => {
        return index + 1;
      },
    },
    {
      title: '业务编号',
      key: 'bussNo',
      width: 170,
      dataIndex: 'bussNo',
    },
    {
      title: '业务范围',
      key: 'leaseMode',
      dataIndex: 'leaseMode',
      customRender: ({ text, record, index }) => {
        return leaseMode.value.find((item) => item.optionCode == text).optionName;
      },
    },

    {
      title: '承租人',
      key: 'custName',
      width: 120,
      dataIndex: 'custName',
    },
    {
      title: '品牌',
      key: 'brandName',
      width: 170,
      dataIndex: 'brandName',
    },
    {
      title: '回购人',
      key: 'hgName',
      width: 170,
      dataIndex: 'hgName',
    },

    {
      title: '融资金额(元)',
      key: 'raiseFunds',
      width: 120,
      dataIndex: 'raiseFunds',
    },

    {
      title: '计划起租日',
      key: 'startDate',
      width: 120,
      dataIndex: 'startDate',
    },
    {
      title: '融资期限',
      key: 'leaseTerm',
      width: 80,
      dataIndex: 'leaseTerm',
      customRender: ({ text, record, index }) => {
        return text + '个月';
      },
    },
    {
      title: '主办名称',
      width: 80,
      key: 'leaseholder',
      dataIndex: 'leaseholder',
    },
    {
      title: '未签约合同',
      width: 80,
      key: 'unsign_count',
      dataIndex: 'unsign_count',
      customRender: ({ text, record, index }) => {
        return text + '个';
      },
    },

    {
      title: '签约中合同',
      width: 80,
      key: 'signing_count',
      dataIndex: 'signing_count',
      customRender: ({ text, record, index }) => {
        return text + '个';
      },
    },
    {
      title: '已签约合同',
      width: 80,
      key: 'signed_count',
      dataIndex: 'signed_count',
      customRender: ({ text, record, index }) => {
        return text + '个';
      },
    },
    {
      title: '代扣状态',
      width: 80,
      key: 'deductStatus',
      dataIndex: 'deductStatus',
      customRender: ({ text, record, index }) => {
        return text == '01' ? '未签约' : '';
      },
    },
    {
      title: '审批状态',
      width: 80,
      key: 'taskName',
      dataIndex: 'taskName',
      customRender: ({ text, record, index }) => {
        return record.redoReason ? `${text}-${record.redoReason}` : text;
      },
    },
    {
      title: '任务名称',
      width: 80,
      key: 'taskTypeName',
      dataIndex: 'taskTypeName',
    },
    {
      title: '内部收益率',
      key: 'earningRate',
      dataIndex: 'earningRate',
      customRender: ({text}) => {
        return text*100+'%';
      },
    },
    {
      title: '操作',
      key: 'operate',
      dataIndex: 'operate',
      slots: { customRender: 'operate' },
    },
  ]);
  const onSubmit = () => {};
  const onView = () => {
    router.push({ path: '/htSign/htDetail' });
  };
  async function init() {
    const res1 = await htSignApi.getConstantConfig({ dictionaryCode: ['leaseMode'] });
    if (res1.code == 0) {
      leaseMode.value = res.data.leaseMode;
    }
    const res2 = await htSignApi.getSponsorList({ parCode: 'ASSIST_ROLE', type: '1' });
    if (res1.code == 0) {
      sponsorList.value = res.data;
    }
  }
  onMounted(() => {
    init();
  });
</script>
<style scoped lang="less">
  @import url(../rzApply/index.less);
  .app-page {
    width: 100%;
    box-sizing: border-box;
    padding: 16px 24px;
    .query-form {
      margin-bottom: 20px;
    }
  }
</style>
